# -*- coding: utf_8 -*-
# @Create   : 2021/8/20 9:29
# @Author   : yh
# @Remark   : 配置管理model层
from enum import Enum

from mxsoftpy import Model
from pydantic import constr


class VideoConfDeviceModel(Model):
    """
    基础数据模型
    """
    name: constr(min_length=1, max_length=50)
    state: int = 1
    desc: constr(min_length=1, max_length=200) = ''


class DeviceTypeModel(VideoConfDeviceModel):
    """设备类型"""
    pass


class StreamModel(VideoConfDeviceModel):
    value: int
    """码流"""
    pass


class ResolutionModel(VideoConfDeviceModel):
    """分辨率"""
    pass


class TaskCycleModel(VideoConfDeviceModel):
    """任务周期"""
    minute: int


class TestItemsModel(VideoConfDeviceModel):
    """检测项目类型"""
    min: float = 1.0
    max: float = 100.0
    expression: constr(min_length=1, max_length=50)
    reference: float
    func_name: constr(min_length=1, max_length=50)
    func_args: constr(min_length=1, max_length=50) = 'handle'


class TestValueEnum(str, Enum):
    """
    检测项目结果枚举类
    """
    normal = '1'  # 正常
    fault = '3'   # 故障
    failed = '2'  # 失败
    all = ''      # 全部
